package com.icebergteam.warfacewidget.core.connection.services;

import java.util.ArrayList;

import android.net.Uri;

public class ServiceParameters {
	ArrayList<String> parameters;
	
	public ServiceParameters() {
		parameters = new ArrayList<String>();
	}
	
	public void addParameter(String key, int value) {
		addParameter(key, Integer.toString(value));
	}
	
	public void addParameter(String key, double value) {
		addParameter(key, Double.toString(value));
	}
	
	public void addParameter(String key, boolean value) {
		addParameter(key, Boolean.toString(value));
	}
	
	public void addParameter(String key, String value) {
		parameters.add(key + "=" + Uri.encode(value));
	}
	
	public String getParameters() {
		String result = "";
		for (int i = 0; i < parameters.size(); i++) {
			result += parameters.get(i) + (i != parameters.size() - 1 ? "&" : "");
		}
		return result;
	}
	
	public void clear() {
		parameters.clear();
	}
}
